<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 基本数据类型 值传递/值拷贝 */
        // var a = 100
        // var b = a
        // b += 100
        // console.log(a,b);//100 200

        /* 引用数据类型 */
        var a = { salary: 100 }
        var b = a
        b.salary += 100
        console.log(b.salary);//200
        console.log(a.salary);//200

        a.salary -= 50
        console.log(a.salary);//150
        console.log(b.salary);//150

        /* 
        欢哥是对象 
        将欢哥赋值给别人时 相当于将欢哥的地址丢给它
        x的值是欢哥的地址 那么修改x中的内容 欢哥也会收到影响 反之亦然
        var x = broJet
        */
        var broJet = {
            name:"杰哥",
            salary:15000
        }

        // 加薪函数收到实参number的拷贝
        function raiseSalary1(salary){
            // 修改当前副本不会影响到实参的值
            salary *= 2
            console.log("salary in funciton=",salary);
        }
        raiseSalary1(broJet.salary)//将杰哥的薪水（number）值拷贝给加薪函数
        console.log(broJet.salary);//15000

        // obj实际收到杰哥家的地址
        function raiseSalary2(obj){
            // 按照地址杀到杰哥家 无情将其薪水翻倍
            obj.salary *= 2
        }
        raiseSalary2(broJet)//杰哥家的地址给到加薪函数
        console.log(broJet.salary);//30000

    </script>
</body>

</html>